/******************************************************************
*
* Copyright 2010 Darshan M Sonde
*
* This file is part of ddots.
*
* ddots is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ddots is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ddots.  If not, see <http://www.gnu.org/licenses/>.
*
*********************************************************************/

#ifndef ROHMBUS_H
#define ROHMBUS_H

#include <QtGui>
#include "game.h"

class Rohmbus : public QObject,public QGraphicsPolygonItem
{
    Q_OBJECT
public:
    Rohmbus(QGraphicsItem *parent=0);
    Rohmbus(const QPolygonF &poly,QGraphicsItem *parent=0);

    //sets to one state, once in off state, only api can set it to on state.
    void mousePressEvent( QGraphicsSceneMouseEvent *event);
    void hoverEnterEvent( QGraphicsSceneHoverEvent *event );
    void hoverLeaveEvent( QGraphicsSceneHoverEvent *event );

    void setOn(bool on=true); //listen to mouse events or not
    bool on(){ return mOn; }
    
    void setRowType(bool isRowType=true);
    bool rowType(){ return mRowType; }
    
    void setStartPoint(const QPoint& p){ mStartPoint  = p; }
    QPoint startPoint(){ return mStartPoint; }
    
    void setEndPoint(const QPoint& p){ mEndPoint = p; }
    QPoint endPoint(){ return mEndPoint; }

signals:
    void clicked(QPoint start,QPoint end); //only emited when on

protected:
    void createLine();

private:
    bool mOn;
    bool mRowType;
    QPoint mStartPoint;
    QPoint mEndPoint;

    QGraphicsLineItem *mDash;    
};

#endif // ROHMBUS_H
